package com.sinosoft.dsp.persistence.businessconcept;

import java.util.ArrayList;
import java.util.List;

import com.sinosoft.dsp.system.utils.PersistenceUtils;

public abstract class AbstractBusinessConceptMainEntity extends
		AbstractBusinessConceptEntity implements IBusinessConceptMainEntity {

	@Override
	public boolean checkUpdate() {
		if (getTimestamp() != null && !"".equals(getTimestamp()))
			if (getTimestamp().equals(getHashCode())) {
				return true;
			}
		return false;
	}

	@Override
	public void setHashCodeData(List<String> list) {
		super.setHashCodeData(list);
		list.add(String.valueOf(getCreateTime()));
		list.add(getCreator());
		list.add(getCreatorDepartment());
		list.add(String.valueOf(getLastUpdateTime()));
		list.add(getLastUpdator());
		list.add(getLastUpdatorDepartment());
	}

	@Override
	public String getHashCode() {
		List<String> list = new ArrayList<String>();
		setHashCodeData(list);
		return PersistenceUtils.hash(list.toArray(new String[list.size()]));
	}

	@Override
	public void createNewTimestamp() {
		setTimestamp(getHashCode());
	}

}
